<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-1.7.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	  $("input[name=tj]").first().click(function(){
		/*var name= document.getElementById('userName');
		if(name.value==''||name.value=='undifined'){
			document.getElementById('msgName').innerText="*请输入名字";
			document.getElementById('msgName').style.color="red";
		}*/
		
		//ID选择器
		if($("#userName").val()==''||$("#userName").val()=='undifined'){
			$("#msgName").text("*请输入名字");
			$("#msgName").css("color","red");
		}
		
		//$("#userName").val("abcdef");
		
		/*var ses= document.getElementsByName('sex');
		alert(ses.length);
		for(var i=0;i<ses.length;i++){
			alert(ses[i].value);
		}*/
		
		//属性选择器
		$("input[name=sex]").each(function(){
		    alert($(this).val());
		 });
		
		/*var inputs= document.getElementsByTagName('input');
		alert(inputs.length);
		for(var i=0;i<inputs.length;i++){
			alert(inputs[i].name);
		}*/
		
		//alert($("input").last().attr("name"));
		//标签选择器
		$("input").each(function(){
		    alert($(this).attr("name"))
		 });
	});
});

</script>
</head>
<body>
	<form action="">
		<table width="300px" height="300px" border="1" bordercolor="blue" cellspacing="0">
			<tr>
				<td>用户名：</td>
				<td><input id="userName" name="userName" type="text" value="5242455"><span id="msgName"></span></td><!-- 文本输入框 -->
			</tr>
			<tr>
				<td>密码：</td>
				<td><input name="psw1" type="password"></td><!-- 密码输入框 -->
			</tr>
			<tr>
				<td>确认密码：</td>
				<td><input name="psw2" type="password"></td><!-- 密码输入框 -->
			</tr>
			<tr>
				<td>邮箱：</td>
				<td><input name="email" type="text"></td><!-- 文本输入框 -->
			</tr>
			<tr>
				<td>性别：</td>
				<td><input name="sex" type="radio" value="男">男<input name="sex" type="radio" value="女">女</td><!-- 单选按钮 -->
			</tr>
			<tr>
				<td>兴趣爱好：</td>
				<td><input name="enjoy" type="checkbox">唱歌<input name="enjoy" type="checkbox">画画</td><!-- 复选按钮 -->
			</tr>
			<tr>
				<td>性格描述：</td>
				<td><textarea rows="10" cols="20"></textarea></td><!-- 文本域 -->
			</tr>
			
			<tr>
				<td colspan="2"><input id="tj" name="tj" type="button" value="注册"></td>
			</tr>
		</table>

	</form>
</body>
</html>